import { defineConfig } from 'vite';
import { resolve } from 'path';
import vue from '@vitejs/plugin-vue';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import { viteMockServe } from 'vite-plugin-mock';
export default defineConfig({
  // 在这里增加 base 写子路径，注意这里前后都要有斜杠
  base: '/',
  server: {
    port: 8000
  },
  plugins: [
    vue({
      script: {
        // 开启defineModel
        defineModel: true
      }
    }),
    AutoImport({
      imports: ['vue', 'vue-router'],
      resolvers: [ElementPlusResolver()],
      eslintrc: {
        enabled: true,
        // 生成自动导入json文件位置
        filepath: './.eslintrc-auto-import.json'
      }
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    }),
    viteMockServe({
      mockPath: './mock/'
    })
  ],
  resolve: {
    alias: {
      '@/': resolve(__dirname, 'src') + '/'
    }
  }
});
